; common.inc
; Global definitions
;

; constants

M_NTSC		= $05
M_PAL		= $0C

VIDEO_BASE	= $1000
CHAR_BASE	= $1000
VIDEO_PAGES	= 2
COLOR_BASE  = $9400

VIC_BASE = $9000

VIA1_BASE = $9110
VIA2_BASE = $9120

MAX_COLS = 26
MAX_ROWS = 16

MAX_WIDTH = MAX_COLS*8
MAX_HEIGHT = MAX_ROWS*16

VIDEO_SIZE = MAX_COLS*MAX_ROWS

WARMSTART_VECTOR = $0302
IRQ_VECTOR = $0314
BRK_VECTOR = $0316

; structures

	CUR_BUF_SIZE = 4

	.struct BgBuf
		left		.byte
		top			.byte
		width		.byte
		height		.byte
		buffer		.byte 4 ; CUR_BUF_SIZE
	.endstruct
	
	.struct Frame
		addr		.word
		ch_height 	.byte
		px_height	.word
		ch_length	.byte
	.endstruct
	
	.struct Bitmap
		width		.byte
		height		.byte
		buf_ptr		.word
	.endstruct
	
	.struct Event
		type		.byte
	.endstruct
	
	.struct MouseEvent
		type	.byte
		mx		.byte
		my		.byte
		dx		.word
		dy		.word
		btn		.byte
	.endstruct

	.struct KeyEvent
		type	.byte
		ddstate .byte
		scncode	.byte
		scrcode	.byte
		petscii .byte
	.endstruct
	
	.struct WinEvent
		type	.byte
		win		.byte
	.endstruct
	
	.struct String
		size	.byte
		len		.byte
		data	.byte
	.endstruct
	
; event types
	MOUSE_EVENT = %10000000
	EVT_MOUSE_MOVE =	MOUSE_EVENT+0
	EVT_MOUSE_DOWN =	MOUSE_EVENT+1
	EVT_MOUSE_UP =   	MOUSE_EVENT+2
	EVT_MOUSE_ENTER =	MOUSE_EVENT+3
	EVT_MOUSE_LEAVE =	MOUSE_EVENT+4
	KEY_EVENT = %01000000
	EVT_KEY_DOWN = KEY_EVENT
	EVT_KEY_UP =   KEY_EVENT+1
	WIN_EVENT = %00100000
	EVT_WIN_DESTROY =  WIN_EVENT
	EVT_WIN_KILLFOCUS = WIN_EVENT+1
	EVT_WIN_HIDE = WIN_EVENT+2
	EVT_WIN_SETFOCUS = WIN_EVENT+3

; Dead key states
	DEAD_KEY_CBM = 2
	DEAD_KEY_LSHIFT = 1
	DEAD_KEY_RSHIFT = 8
	DEAD_KEY_CTRL = 4
	DEAD_KEY_SHIFT_MASK = DEAD_KEY_LSHIFT|DEAD_KEY_RSHIFT

; graphic modes
	GM_CLEAR = 0
	GM_SET = 1
	GM_XOR = 2

; cursor styles
	CURSOR_WAIT = 0			; Wait cursor
	CURSOR_ARROW = 1		; Arrow, default for active windows
	CURSOR_HAND = 2			; Hand, default for buttons
	CURSOR_BEAM = 3			; Beam, default for input field (edit)
	CURSOR_CROSS = 4		; Cross, default for root window (screen)
	CURSOR_WINDOW = 5		; Window, default for deactivated windows
	CURSOR_ACTIVATE = 6		; Triangle (pointing upwards)
	CURSOR_MOVE = 7

; VFrame flags
	FFLG_PERM = 1			; Permanent, never deactivated by new frames.
	FFLG_TEMP = 2			; Temporary, may be destroyed for new frames.
	FFLG_REAL = 4			; Realised, has screen block.
	FFLG_USED = 8			; Used, data structure is in use.

; Window styles
	WSTYLE_ROOT = 1			; Window has its own frame
	WSTYLE_BORDER = 2		; Has border
	WSTYLE_HASTITLE = 4		; Has title (Text goes to title bar)
	WSTYLE_TXLEFT = 8		; Left aligned text
	WSTYLE_TXRIGHT = 16		; Right aligned text
	WSTYLE_BCKGND = 32		; Has background
	WSTYLE_TXTOP = 64		; Top aligned text (ignored for title text)
	WSTYLE_TXBOTTOM = 128	; Bottom aligned text (ignored for title text)
	
; Edit flag
	EDIT_HAS_FOCUS = 128
	EDIT_POS_MASK = $7F

; Window types for method initialisation (win_settype)
	WTYPE_WINDOW = 0
	WTYPE_BUTTON = 1
	WTYPE_EDIT = 2

; Button flags
	BSTATE_UP	= 0
	BSTATE_DOWN = 1

; end

	.import panic
